package com.ocom.payconfig.dao;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.ocom.common.entity.payconfig.EntityDishesPrice;
import com.ocom.common.pojo.payconfig.MachPriceVo;
import com.ocom.common.vo.payconfig.MealMenuInfoVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface IDaoDishesPrice extends BaseMapper<EntityDishesPrice> {


    @Select({"<script>",
            "select \n" +
                    "d.*,p.point_name \n" +
                    "FROM dishes_price as d \n" +
                    "left join xf_point_info as p on d.point_id = p.point_id \n" +
                    "where d.com_id =#{comId} and d.merch_id = #{merchId} and d.price &gt;= 0 "+
                    " <when test=\"dishesIds.size()>0 \" > "+
                        "and d.dishes_id in" +
                        "<foreach collection='dishesIds' item='item' open='(' separator=',' close=')'>" +
                            "#{item}" +
                        "</foreach>"+
                    " </when> "+
            "</script>"})
    List<EntityDishesPrice> selectDishesPriceList(Long comId, Long merchId, List<Integer> dishesIds);



//    @Select({"<script>",
//            "select \n" +
//                    "dishes_id,price \n" +
//                    "FROM dishes_price \n" +
//                    "left join xf_point_info as p on d.point_id = p.point_id \n" +
//                    "where d.com_id =#{comId} and d.merch_id = #{merchId} and d.price &gt;= 0 "+
//                    " <when test=\"dishesIds.size()>0 \" > "+
//                    "and d.dishes_id in" +
//                    "<foreach collection='dishesIds' item='item' open='(' separator=',' close=')'>" +
//                    "#{item}" +
//                    "</foreach>"+
//                    " </when> "+
//                    "</script>"})
//    List<EntityDishesPrice> selectDishesPriceList2(Long comId, Long merchId, List<Integer> dishesIds);




    @Select({"<script>",
            "SELECT p.price,p.price_mode as priceMode,d.* " +
                    "FROM dishes_price p " +
                    "RIGHT JOIN dishes_info d on d.dishes_id = p.dishes_id and p.point_id=0 " +
                    "where  d.status =1 and " +
                    "d.dishes_class_id in " +
                    "<foreach collection='calssIds' item='item' open='(' separator=',' close=')'>" +
                    "#{item}" +
                    "</foreach>"+
                    "and d.com_id = #{comId}  order by d.dishes_id asc " +
            "</script>"})
    List<MachPriceVo> getMqttPrices(Long comId, List<Integer> calssIds);

    @Select("select  d.dishes_id,d.dishes_name " +
            " from  dishes_info  d " +
            "left  join dishes_price p  on  d.com_id =p.com_id and d.merch_id=p.merch_id  and d.dishes_id=p.dishes_id " +
            " ${ew.customSqlSegment}")
    List<MealMenuInfoVo> getMealMenuInfo(@Param(Constants.WRAPPER) Wrapper wrapper);
}
